package com.common.www.bean.entity;


import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;

public class Result<T> implements Serializable {
    public Integer code;
    public String message;
    public T data;
    public Exception exception = null;
    private Integer page;
    private Integer totalPage;
    private Long totalElements;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Long getTotalElements() {
        return totalElements;
    }

    public void setTotalElements(Long totalElements) {
        this.totalElements = totalElements;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getException() {
        try {
            if (this.exception == null) {
                return null;
            } else {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                this.exception.printStackTrace(pw);
                return sw.toString();
            }
        } catch (Exception var3) {
            return "bad getErrorInfoFromException";
        }
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                ", exception=" + exception +
                ", page=" + page +
                ", totalPage=" + totalPage +
                ", totalElements=" + totalElements +
                '}';
    }
}
